﻿Ext.define('Sofia.controller.Run',
{
    extend: 'Ext.app.Controller',
    views: ['Sidebar', 'tab.Run'],

    refs:
    [{
        selector: '.sidebar',
        ref: 'sideBar'
    }],

    init: function () {
        this.control(
        {
            '.viewport > .panel > #HeaderPanel > #RunButton':
            {
                click: this.onRunClick
            },

            '#1Radio':
            {
                change: this.showAlgorithmMenu
            },

            '#2Radio':
            {
                change: this.showAlgorithmMenu
            },

            '#3Radio':
            {
                change: this.showAlgorithmMenu
            },

            '#MDRadio':
            {
                change: this.showMDMenu
            },

            '#MCRadio':
            {
                change: this.showMCMenu
            },

            '#MinRadio':
            {
                change: this.showMinMenu
            },

            '#thermRadio1':
            {
                change: this.showThermMenu
            },

            '#thermRadio2':
            {
                change: this.showThermMenu
            }
        });
    },

    onRunClick: function () {
        var sideBar = this.getSideBar();
        sideBar.setActiveTab(1); //Run tab
    },

    showAlgorithmMenu: function (dimension,newValue,oldValue) {
        if( newValue === true) 
            {
                Ext.get('algorithmMenu').show();
                (Ext.getCmp('runPanel')).doLayout();
            } 

    },

    showMDMenu: function(algorithm,newValue,oldValue) {
        if( newValue === true) 
            {
                Ext.get('MDMenu').show();
                (Ext.getCmp('runPanel')).doLayout();
            } 
    },

    showMCMenu: function(algorithm,newValue,oldValue) {
        if( newValue === true) 
            {
                Ext.get('MCMenu').show();
                (Ext.getCmp('runPanel')).doLayout();
            } 
    },

    showMinMenu: function(algorithm,newValue,oldValue) {
        if( newValue === true) 
            {
                Ext.get('minMenu').show();
                (Ext.getCmp('runPanel')).doLayout();
            } 
    },

    showThermMenu: function(algorithm,newValue,oldValue) {
        if( newValue === true) 
            {
                Ext.get('thermMenu').show();
                (Ext.getCmp('runPanel')).doLayout();
            } 
    },

    showRunMenu: function(algorithm,newValue,oldValue) {
        if( newValue === true) 
            {
                Ext.get('thermMenu').show();
                (Ext.getCmp('runPanel')).doLayout();
            } 
    }


});